<template>
   <el-menu 
            mode="horizontal"
        >
            <el-sub-menu v-for="(menu,index) in menus" 
                :key="index" 
                :index="index"
                :popper-class="'poper'+index"
            >
                <template v-slot:title>
                    <img :src="menu.icon"  />
                    <span>{{menu.name}}</span>
                </template>
                <template v-slot:default v-if="index == 0">
                    <el-menu-item  v-for="(subMenu,subIndex) in menu.children" :key="subIndex">
                        <img :src="subMenu.icon"  />
                        <div class="chartMenu">
                            <div class="chartMenuItem" v-for="(subMenuChild,subMenuChildIndex) in subMenu.children" :key="subMenuChildIndex">
                                <img :src="subMenuChild.img" />
                                <span>{{ subMenuChild.name }}</span>
                            </div>
                        </div>
                    </el-menu-item> 
                </template>
                <template v-slot:default v-else>
                    <el-menu-item class=""  v-for="(subMenu,subIndex) in menu.children" :key="subIndex">
                        <img :src="subMenu.icon"  />
                        <span>{{subMenu.name}}</span>
                        
                    </el-menu-item> 
                </template>
            </el-sub-menu>
        </el-menu>
</template>

<script setup lang="ts">
    //菜单图标
    import useMenuImageHooks from '@/hooks/useMenuHooks';
    const { 
        menus } = useMenuImageHooks();
</script>

<style scoped lang="scss">
    .el-menu{
        display: flex;
        flex-direction: row;
        background: transparent;
        border: 0;
        height: 100%;
        .el-sub-menu{
            width: 80px;
        }
        :deep(.el-sub-menu__title){
            height: 100%;
            display: flex;
            flex-direction: column;
            justify-content: center;
            padding: 0 20px;
            span{
                height: 20px;
                color: #d7dde0;
                line-height: 20px;
                font-size: 12px;
            }

        }
        :deep(.el-sub-menu__title):hover{
            background: #494a4d !important;
        }
        :deep(.el-sub-menu__icon-arrow){
            display: none;
        }
        
    }
</style>

<style>
    .el-popper{
        transform: translateY(-8px);
        border: 0 !important;
    }
    .el-menu--popup{
        background: #252626;
        width: 350px;
        height: 235px !important;
        overflow: auto;
        display: flex;
        flex-wrap: wrap;
        align-content: flex-start;
    }
    .el-menu--popup .el-menu-item{
        padding: 20px;
        background: #252626 !important;
        width: 33%;
        height: 75px !important;
        display: flex;
        flex-direction: column;
        img{
            width: 90%;
        }
        span{
            color: #c8c8c8;
            font-size: 12px;
            height: 20px;
            line-height: 20px;
        }
        &:hover{
            span{
                color: #fff;
            }
        }
    }
    .poper0 .el-menu--popup{
        display: block;
        padding: 0;
        position: relative;
        .el-menu-item{
            width: 50px;
            height: 25% !important;
            background: #353738 !important;
            display: flex;
            justify-content: center;
            position: static;
            img{
                width: 20px;
            }
            &:hover{
                background: rgb(35, 97, 190) !important;
                .chartMenu{
                    display: flex;
                }
            }
            &:first-child{
                .chartMenu{
                    display: flex !important;
                }
            }
            .chartMenu{
                display: none;
                color: white;
                background: #252626;
                width: 300px;
                height: 235px;
                overflow: auto;
                position: absolute;
                left: 50px;
                top: 0px;
                flex-wrap: wrap;
                align-content: flex-start;
                .chartMenuItem{
                    width: 33%;
                    height: 75px !important;
                    display: flex;
                    flex-direction: column;
                    align-items: center;
                    justify-content: center;
                    padding: 5px;
                    box-sizing: border-box;
                    img{
                        width: 90%;
                    }
                    span{
                        color: #c8c8c8;
                        font-size: 12px;
                        height: 20px;
                        line-height: 20px;
                    }
                    &:hover{
                        span{
                            color: #fff;
                        }
                    }
                }
            }
        }
    }
</style>